﻿using System;
using System.Collections.Generic;
using System.Linq;

using PortalIntranet.DatabaseComponents;
using PortalIntranet.DatabaseComponents.Seguranca;
using PortalIntranet.ObjectComponents.WebParts.ConteudosHtml;
using PortalIntranet.DatabaseComponents.WebParts;
using PortalIntranet.BusinessComponents.Seguranca;
using PortalIntranet.DatabaseComponents.WebParts.ConteudosHtml;

namespace PortalIntranet.BusinessComponents.WebParts.ConteudosHtml
{
	public class ConteudosHtmlBll
	{
		public static ConteudoHtml Obter(int webpart)
		{
			using (var contexto = new IntranetContexto())
			{
				return contexto.ConteudosHtml
					.Where(c => c.WebPartId == webpart)
					.SingleOrDefault();
			}
		}

		public static WPConteudosHtml ConverterWebPart(WebPart webpart)
		{
			ConteudoHtml conteudo = Obter(webpart.Id);
			WPConteudosHtml wpconteudo = new WPConteudosHtml(webpart);
			wpconteudo.Conteudo = conteudo.Conteudo;
			wpconteudo.Altura = webpart.Altura;

			return wpconteudo;
		}
	}
}
